home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Software / Freeware / Programare / highlight / highlight-W32GUI-2.2-10b-Setup.exe / {app} / src / xhtmlgenerator.cpp < prev    next >
C/C++ Source or Header  |  2005-03-31  |  3KB  |  93 lines

  1. /***************************************************************************
  2.                           htmlcode.cpp  -  description
  3.                              -------------------
  4.     begin                : Wed Nov 28 2001
  5.     copyright            : (C) 2001 by AndrΘ Simon
  6.     email                : andre.simon1@gmx.de
  7.  ***************************************************************************/
  8.  
  9. /***************************************************************************
  10.  *                                                                         *
  11.  *   This program is free software; you can redistribute it and/or modify  *
  12.  *   it under the terms of the GNU General Public License as published by  *
  13.  *   the Free Software Foundation; either version 2 of the License, or     *
  14.  *   (at your option) any later version.                                   *
  15.  *                                                                         *
  16.  ***************************************************************************/
  17.  
  18. #include "xhtmlgenerator.h"
  19.  
  20. using namespace std;
  21.  
  22. namespace highlight {
  23.  
  24. XHtmlGenerator::XHtmlGenerator(void)
  25. {}
  26.  
  27. XHtmlGenerator::XHtmlGenerator (
  28.   const string &cssStyle,
  29.   const string &enc,
  30.   bool omitEnc,
  31.   bool withAnchors)
  32.     : HtmlGenerator(cssStyle, enc, omitEnc, withAnchors)
  33. {
  34.    fileSuffix=".xhtml";
  35.    brTag="<br />";
  36.    hrTag="<hr />";
  37.    idAttr="id";
  38.  
  39.   HTML_FOOTER=
  40.   "\n</body>\n</html>\n<!--XHTML generated by highlight "
  41.   HIGHLIGHT_VERSION
  42.   ", "
  43.   HIGHLIGHT_URL
  44.   "-->\n";
  45. }
  46.  
  47. string XHtmlGenerator::getHeaderStart(const string &title){
  48.     ostringstream header;
  49.     header << "<?xml version=\"1.0\"";
  50.     if (!omitEncoding) {
  51.       header << " encoding=\"" << encoding << "\"";
  52.     }
  53.     header << "?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\""
  54.            << "  \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
  55.            << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
  56.            << "<head>\n<title>" << title << "</title>\n";
  57.  
  58.     return header.str();
  59. }
  60.  
  61.  
  62. string XHtmlGenerator::getHeader(const string &title)
  63. {
  64.   ostringstream osPart1;
  65.   osPart1 << getHeaderStart((title.empty())?"Source file":title );
  66.  
  67.   if (langInfo.getSyntaxHighlight())
  68.     {
  69.       if (includeStyleDef)    //CSS-Definition in HTML-<head> einfuegen
  70.         {
  71.           osPart1 << "<style type=\"text/css\">\n";
  72.           osPart1 << "<![CDATA[\n";
  73.           osPart1 << getStyleDefinition();
  74.           osPart1 << CodeGenerator::readUserStyleDef();
  75.           osPart1 << "]]>\n";
  76.           osPart1 << "</style>\n";
  77.         }
  78.       else  //Referenz auf CSS-Datei einfuegen
  79.         {
  80.           osPart1 << "<link rel=\"stylesheet\" type=\"text/css\" href=\""
  81.                   << getStyleOutputPath()
  82.                   << "\""
  83.                   << "/"
  84.                   << ">\n";
  85.         }
  86.     }
  87.     osPart1 << "</head>\n<body class=\"hl\">\n<pre class=\"hl\">";
  88.  
  89.   return osPart1.str();
  90. }
  91.  
  92. }
  93.